import { IParam } from '@core';
import { LawExpressUIServiceBase } from './law-express-ui-service-base';

/**
 * 法律速递UI服务
 *
 * @export
 * @class LawExpressUIService
 * @extends LawExpressUIServiceBase
 */
export class LawExpressUIService extends LawExpressUIServiceBase {

    /**
     * 基础UI服务实例
     * 
     * @private
     * @type { LawExpressUIService }
     * @memberof LawExpressUIService
     */
    private static basicUIServiceInstance: LawExpressUIService;

    /**
     * UI服务存储Map对象
     *
     * @private
     * @type {Map<string, any>}
     * @memberof LawExpressUIService
     */
    private static UIServiceMap: Map<string, any> = new Map();

    /**
     * Creates an instance of LawExpressUIService.
     * @memberof LawExpressUIService
     */
    constructor(opts?: IParam) {
        super(opts);
    }

    /**
     * 获取实例
     *
     * @static
     * @param 应用上下文
     * @return {*}  { LawExpressUIService }
     * @memberof LawExpressUIService
     */
    static getInstance(opts?: IParam): LawExpressUIService {
         if (!this.basicUIServiceInstance) {
            this.basicUIServiceInstance = new LawExpressUIService(opts);
        }
        if (!opts || !opts.srfdynainstid) {
            return this.basicUIServiceInstance;
        } else {
            if (!LawExpressUIService.UIServiceMap.get(opts.srfdynainstid)) {
                LawExpressUIService.UIServiceMap.set(opts.srfdynainstid, new LawExpressUIService(opts));
            }
            return LawExpressUIService.UIServiceMap.get(opts.srfdynainstid);
        }
    }
}
export default LawExpressUIService;